<?php
	$xtpl_main->assign ( "page_title", "Report" );
	//--
	
	if(isset($_GET['u'])){
		$u = intval($_GET['u']);
		
		//-- Check member
		$rsCheckMemberExists = mysql_query("SELECT member_displayname FROM member WHERE member_id = '".$u."' LIMIT 1");
		if(mysql_num_rows($rsCheckMemberExists) > 0){
			$rsGetMemberReport = mysql_query("
												SELECT t.task_description, r.report_time, p.project_name 
												FROM report r 
												INNER JOIN task t ON t.task_id = r.task_id 
												INNER JOIN project p ON p.project_id = r.project_id 
												WHERE 
													r.report_created_date = '".date('Y-m-d')."' 
													AND r.member_id = '".$u."'
											 ");
			if(mysql_num_rows($rsGetMemberReport) > 0){
				$iCountTask = 1;
				while($rowListMemberReport = mysql_fetch_array($rsGetMemberReport)){
					$rowListMemberReport['iCountTask'] = $iCountTask;
					$iCountTask++;
					$xtpl->assign("listMemberReport", $rowListMemberReport);
					$xtpl->parse("center.MemberHasReport.listMemberReport");
				}
				$xtpl->parse("center.MemberHasReport");
			}else{//-- no report
				$xtpl->parse("center.MemberHasNoReport");
			}
			$rowCheckMemberExists = mysql_fetch_array($rsCheckMemberExists);
			$member_displayname = $rowCheckMemberExists['member_displayname'];
		}else{ //-- member not found
			$member_displayname = 'No One';
			$xtpl->parse("center.MemberNotFound");
		}
		$xtpl->assign("thisMemberDisplayName", $member_displayname);
	}
?>